package com.interest.controller;

import com.interest.controller.builder.ListModelAndViewBuilder;
import com.interest.modules.trending.entity.Trending;
import com.interest.modules.trending.service.GithubTrendingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/github/trending")
public class TrendingController {

    @Autowired
    private GithubTrendingService githubTrendingService;

    @RequestMapping("/list")
    public ModelAndView getList() {
        List<Trending> list = githubTrendingService.getList();
        return new ListModelAndViewBuilder("github/trending", list).build();
    }
}
